#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool cmp(pair<int, int> e1, pair<int, int> e2)
{
	if (e1.first != e2.first)
		return e1.first > e2.first;
	else
		return e1.second < e2.second;
}

int main()
{
	int r = 0, c = 0, k = 0, n = 0;
	cin >> r >> c >> k >> n;

	vector< pair<int, int> > arr(r + 1);
	for (int i = 1; i <= r; ++i)
	{
		arr[i] = make_pair(0, i);
	}
	for (int i = 0; i < n; ++i)
	{
		int x = 0, y = 0;
		cin >> x >> y;
		arr[x].first++;
	}
	sort(arr.begin(), arr.end(), cmp);
	int sum = 0;
	for (int i = 0; i < k; ++i)
	{
		sum += arr[i].first;
	}
	cout << sum << endl;
	vector<int> arry(k);
	for (int i = 0; i < k; ++i)
	{
		arry[i] = arr[i].second;
	}
	sort(arry.begin(), arry.end());
	for (int i = 0; i < k; ++i)
	{
		cout << arry[i] << " ";
	}
	return 0;
}